//
//  ImgAnimationViewController.m
//  UITest
//
//  Created by wp w on 12-6-7.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "ImgAnimationViewController.h"

@interface ImgAnimationViewController ()

@end

@implementation ImgAnimationViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    NSArray *arrImages = [[NSArray alloc] initWithObjects:
						  [UIImage imageNamed:@"apple.png"],
						  [UIImage imageNamed:@"apple2.png"],
						  [UIImage imageNamed:@"apple3.png"],nil];
	
    //创建imgview
	CGRect viewFrame = CGRectMake(0,0,200,200);
	UIImageView *myImageView = [[UIImageView alloc] initWithFrame:viewFrame];
	
    //这个动画时imgview类中包含的动画
    //设置imgview需要显示的图片数组
	[myImageView setAnimationImages:arrImages];
	//设置图片数组重复次数和显示一张图片的时间
	[myImageView setAnimationRepeatCount:0];
	[myImageView setAnimationDuration:2];
	
    //把imgview添加到view中
	[self.view addSubview:myImageView];
	[myImageView startAnimating];
	
	[arrImages release];
	[myImageView release];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
